package com.blackfish.type;

import java.util.List;

import com.blackfish.common.model.Type;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

public class TypeService {
private static final Type dao = new Type().dao();
	
	public String getNameById(int id){
			return this.findById(id).getName();
	}
	
	public List<Type> findAll(){
		return dao.find("select * from type order by id asc");
	}
	
	public Type findById(int id) {
		return dao.findById(id);
	}
	
	public void deleteById(int id) {
		dao.deleteById(id);
	}
	
	public int getIdByName(String name){
		return dao.findFirst("select * from type where name='"+name+"'").getId();
	}
	
	public List<Record> getAllJson(){
		return Db.find("");
	}
}
